﻿using log4net;
using log4net.Config;
using log4net.Repository;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace AgencyManagerSystem.Common
{
    public static class LogHelper
    {
        static ILoggerRepository repository ;
        static ILog log;
        static LogHelper()
        {
            repository = LogManager.CreateRepository("NETCoreRepository");
            string path = Path.GetDirectoryName(typeof(LogHelper).Assembly.Location) + "/log4net.config";
            XmlConfigurator.Configure(repository, new FileInfo(path));
            log = LogManager.GetLogger(repository.Name, "System");
        }
        public static void Log(object sender, string message)
        {
            log.InfoFormat("[Info]{0}:{1}",sender,message);
        }
        public static void Err(object sender, string message)
        {
            log.ErrorFormat("[Error]{0}:{1}", sender, message);

        }
        public static void Warn(object sender, string message)
        {
            log.WarnFormat("[Warn]{0}:{1}", sender, message);

        }
        public static void Debug(object sender, string message)
        {
            log.DebugFormat("[Debug]{0}:{1}", sender, message);

        }
    }
}
